<?php
$this->breadcrumbs = array(
    'Bares' => array('index'),
    $model->establecimiento,
);

$this->menu = array(
    array('label' => 'List bar', 'url' => array('index')),
    array('label' => 'Create bar', 'url' => array('create')),
    array('label' => 'Update bar', 'url' => array('update', 'id' => $model->id)),
    array('label' => 'Delete bar', 'url' => '#', 'linkOptions' => array('submit' => array('delete', 'id' => $model->id), 'confirm' => 'Are you sure you want to delete this item?')),
    array('label' => 'Manage bar', 'url' => array('admin')),
);
?>

<h1><?php echo $model->establecimiento; ?></h1>

<div class="detalle">
  <?php
  $this->widget('zii.widgets.CDetailView', array(
      'data' => $model,
      'attributes' => array(
          'id_user',
          'logotipo',
          'establecimiento',
          'descripcion',
      ),
  ));
  ?>

  <h1>Ofertas</h1>
  <div class="form">
    <?php
    $form = $this->beginWidget('CActiveForm', array(
                'id' => 'familiar-form',
                'enableAjaxValidation' => false,
                'htmlOptions' => array('enctype' => 'multipart/form-data'),
            ));
    ?>

    <div class="bloque" style="width:540px;">
      <h3>Añadir oferta</h3>
      <?php echo $form->errorSummary($modelOferta); ?>

      <div class="row">
        <?php echo $form->labelEx($modelOferta, 'titulo'); ?>
        <?php echo $form->textField($modelOferta, 'titulo'); ?>
        <?php echo $form->error($modelOferta, 'titulo'); ?>
      </div>

      <div class="row">
        <?php echo $form->labelEx($modelOferta, 'descripcion'); ?>
        <?php echo $form->textField($modelOferta, 'descripcion'); ?>
        <?php echo $form->error($modelOferta, 'descripcion'); ?>
      </div>

      <div class="row">
        <div class="row">
          <?php echo $form->labelEx($modelOferta, 'foto'); ?>
          <?php echo CHtml::activeFileField($modelOferta, 'foto'); ?>
          <?php echo $form->error($modelOferta, 'foto'); ?>
        </div>
      </div>

      <div class="row buttons">
        <?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
        </div>
      </div>
    </div>

    <div class="bloque" style="width: 580px;">
    <h3>Listado</h3>
    <div class="list-title" style="width: 650px;">
      <span class="field-inline bold" style="width: 220px;">Titulo</span>
      <span class="field-inline bold" style="width: 130px;"></span>
    </div>
  <?php foreach ($model->ofertas as $oferta) {
 ?>
            <div class="list-item" style="width: 650px;">
              <span class="field-inline" style="width: 220px;"><?php echo $oferta->titulo ?></span>
              <span class="field-inline" style="width: 130px;  text-align: right;">
                <a href="?r=bar/view&id=<?php echo $oferta->id_bar ?>&idoferta=<?php echo $oferta->id ?>">editar</a> |
                <a href="?r=bar/eliminarOferta&id=<?php echo $oferta->id_bar ?>&idoferta=<?php echo $oferta->id ?>">eliminar</a>
              </span>
            </div>
<?php } ?>
        </div>
<?php $this->endWidget(); ?>

          </div><!-- form -->

<?php
          if (count($model->ofertas) < 3) {
            echo CHtml::link("Crear oferta", array('oferta/create', 'id_bar' => $model->id));
          }
?>
